package com.example.demojimmer.application.in.rest.controller;


import com.example.demojimmer.application.dto.Results;
import com.example.demojimmer.domain.userauth.model.entity.dto.CreateUserInput;
import com.example.demojimmer.domain.userauth.model.entity.dto.UserView;
import com.example.demojimmer.domain.userauth.services.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/users")
@RequiredArgsConstructor
public class UserController {
    private final UserService userService;
    //private final AuthenticationManager authenticationManager;

    @PreAuthorize("hasAuthority('/users/register')")
    @PostMapping("/register")
    public Results<UserView> registerUser(@RequestBody CreateUserInput createUserInput) {
        UserView userView = userService.createUser(createUserInput);
        return Results.ok(userView);
    }

    @PreAuthorize("hasAuthority('/users/register2')")
    @PostMapping("/register2")
    public Results<UserView> registerUser2() {
        //UserDto userDto = userService.createUser(createUserDto);
        return Results.ok(null);
    }


}

